﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit.HTMLEditor;
using BLLLaguzziCandidato;
using System.Collections;

namespace LaguzziCandidato
{
    public partial class Destacados : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void gvProyectos_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            foreach (DictionaryEntry de in e.NewValues)
            {
                DateTime currentDate = DateTime.MinValue;
                if (de.Value != null && DateTime.TryParse(de.Value.ToString(), out currentDate))
                {
                    e.NewValues[de.Key] = currentDate.ToString("MM.dd.yyyy");
                    break;
                }
            }
        }

        protected void btnGuardarChota_Click(object sender, EventArgs e)
        {
            TextBox txtTitulo = lvAltaNota.FindControl("txtTitulo") as TextBox;
            Editor editor = lvAltaNota.FindControl("editorTexto") as Editor;
            TextBox txtFecha = lvAltaNota.FindControl("txtFecha") as TextBox;
            TextBox txtOrden = lvAltaNota.FindControl("txtOrden") as TextBox;

            Lagu_Nota nuevaNota = new Lagu_Nota();
            nuevaNota.Titulo = txtTitulo.Text;
            nuevaNota.Texto = editor.Content;
            nuevaNota.Fecha = DateTime.Parse(txtFecha.Text);
            nuevaNota.Orden = int.Parse(txtOrden.Text);

            BLLNota bll = new BLLNota();
            bll.CargarNota(nuevaNota);
            bll.GuardarCambios();

            txtTitulo.Text = editor.Content = txtFecha.Text = txtOrden.Text = string.Empty;
            txtTitulo.Focus();
            gvNotas.DataBind();
        }
    }
}